﻿@model AesApplication.Models.HiringManagerIndexViewModel

@using AesApplication.Models;

@{
    ViewBag.Title = "Index";
}

<h2>@User.Identity.Name Job List</h2>

@* ToList required to prevent trying to make multiple simultaneous queries (an error). *@
@foreach (Department dept in Model.Departments.ToList())
{
    <h3>@dept.Store.Name - @dept.Name</h3>

    <ul>
        @if (dept.Jobs.Where(x=>x.Status == JobStatus.Active).Count() > 0)
        {
            foreach (Job job in dept.Jobs.Where(x=>x.Status == JobStatus.Active))
            {
                <li>
                @Html.ActionLink(
                    String.Format("{0} - {1} application(s)", job.Title, job.Applications.Where(x=>x.Status == ApplicationStatus.AwaitingHire).Count()),
                    "JobGrid",
                    new { id = job.ID })
                </li>
            }
        }
        else
        {
            <i>There are no job openings in this department.</i>
        }
        <p>@Html.ActionLink("(Request New Job Opening)", "RequestJob", new { DeptID = dept.ID })</p>
    </ul>
}